package com.xuecheng.media.service;

import com.xuecheng.base.model.PageParams;
import com.xuecheng.base.model.PageResult;
import com.xuecheng.base.model.RestResponse;
import com.xuecheng.media.model.dto.QueryMediaParamsDto;
import com.xuecheng.media.model.dto.UploadFileParamsDto;
import com.xuecheng.media.model.dto.UploadFileResultDto;
import com.xuecheng.media.model.po.MediaFiles;

import java.io.File;

/**
 * @description 媒资文件管理业务类
 * @author Mr.M
 * @date 2022/9/10 8:55
 * @version 1.0
 */
public interface MediaFileService {

 /**
  * @description 媒资文件查询方法
  * @param pageParams 分页参数
  * @param queryMediaParamsDto 查询条件
  * @return com.xuecheng.base.model.PageResult<com.xuecheng.media.model.po.MediaFiles>
  * @author Mr.M
  * @date 2022/9/10 8:57
 */
 public PageResult<MediaFiles> queryMediaFiels(Long companyId,PageParams pageParams, QueryMediaParamsDto queryMediaParamsDto);

       /**
       * @description 上传文件
       * @param companyId 机构id
       * @param uploadFileParamsDto 文件信息
       * @param localFilePath 文件本地路径
       * @return com.xuecheng.media.model.dto.UploadFileResultDto
       * @author Mr.M
       * @date 2022/9/10 9:01
       */
      public UploadFileResultDto uploadFile(Long companyId, UploadFileParamsDto uploadFileParamsDto, String localFilePath,String objectName);

      public MediaFiles addMediaFilesToDb(Long companyId, UploadFileParamsDto uploadFileParamsDto, String fileMd5, String bucket, String objectName);

      //检查文件是否存在
      public RestResponse<Boolean> checkFile(String fileMd5);

      //检查分块文件是否存在
      public RestResponse<Boolean> checkChunk(String fileMd5, int chunkIndex);

      //上传分块
      public RestResponse uploadChunk(String fileMd5,int chunk,String localChunkFilePath);

      //合并分块
      public RestResponse mergechunks(Long companyId,String fileMd5,int chunkTotal,UploadFileParamsDto uploadFileParamsDto);

      //从minio下载文件
      public File downloadFileFromMinIO(String bucket, String objectName);

      //将文件上传到minio
      public boolean addMediaFilesToMinIO(String localFilePath,String mimeType,String bucket, String objectName);

    MediaFiles getFileById(String mediaId);
}
